package cn.gp.service.impl;

import cn.gp.common.PageInfo;
import cn.gp.entity.Consumer;
import cn.gp.mapper.ConsumerMapper;
import cn.gp.service.ConsumerService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName ConsumerServiceImpl
 * @Description TODO
 * @Author He_Guoping
 * @Date 2023/5/28 13:01
 * @Version 1.0
 */
@Service
public class ConsumerServiceImpl implements ConsumerService {

    @Autowired
    private ConsumerMapper consumerMapper;
    @Override
    public PageInfo<Consumer> page(Integer page, Integer pageSize, String name) {
        PageHelper.startPage(page, pageSize);
        Page<Consumer> p = (Page<Consumer>) consumerMapper.list(name);
        return new PageInfo<>(p.getTotal(), p.getResult());
    }

    @Override
    public Boolean save(Consumer consumer) {
        consumerMapper.save(consumer);
        return true;
    }

    @Override
    public Boolean deleteById(Integer id) {
        consumerMapper.deleteById(id);
        return true;
    }

    @Override
    public boolean update(Consumer consumer) {
        consumerMapper.update(consumer);
        return true;
    }
}
